<template>
	<view class="main">
		<u-navbar :is-back="true" title="申请提现" :background="background" back-icon-color="#000000" title-color="#000"
			title-bold="true">
			<view class="rights" slot="right" @click="router">
				提现记录
			</view>
		</u-navbar>

		<view class="top">
		
			<view class="allmoney">
				<view class="title">
					可提现金额
				</view>
				<text class="smoney">¥{{info.withdraw}}</text>
			</view>
		</view>
		<view class="content">
			<view class="bankcard">
				<view class="bank">
					<text>姓   名：</text><input maxlength="19" type="text" value="" v-model="name" />
				</view>
				<view class="bank">
					<text>银   行：</text><text @click="showbanks">{{bank==''?'请选择银行': bank}}</text>
				</view>
				<view class="bank">
					<text>卡   号：</text><input maxlength="19" type="number" value="" v-model="cardid" />
				</view>
				<view class="idcard">
					<text>开户行：</text><input maxlength="19" type="text" value="" v-model="banker" />
				</view>
			</view>
			<view class="alldraw">
				<view class="tit">
					提现金额
				</view>
				<view class="drawmoney">
					<text>￥</text><input type="text" v-model="money" />
				</view>
				<view class="full_lift">
					<text>可提现金额{{info.withdraw}}元</text>
					<view @click="all">全部提现</view>
				</view>
			</view>

		</view>
		<view class="button" @click="withdraw">
			确认提现
		</view>
		<view class="ps">
			<view class="ps_tit">
				温馨提示：
			</view>
			<text>
				1.提现申请通过后将在1-3个工作日内将提现金额打入您的银行卡
				账户中。

				2.工作日(周六/日法定节气日均除外)16:30之前申请的提现申请当
				天处理。

			</text>
		</view>
		<u-select v-model="showbank" mode="single-column" :list="banklist" @confirm="confirm"></u-select>
	</view>
</template>
<script>
	export default {
		data() {
			return {
				background: {
					backgroundColor: '#fff'
				},
				info: '',
				bank: '',
				cardid: '',
				money: '',
				name:'',
				banker:'',
				showbank: false,
				banklist: [{
					label: '',
					value: '',
					bank_id: '',
				}],
				bank_ids:'',
				
			}
		},
		onLoad() {
			this.getallmoney()

		},
		mounted() {

		},
		onShow() {},
		methods: {
			//银行下拉框
			showbanks() {
				this.showbank = true
			},
			confirm(e) {
				console.log(e[0].label);
				console.log(e[0].value);
				console.log(this.banklist[e[0].value - 1].bank_code);
				this.bank = e[0].label
				this.bank_ids=e[0].value
			},
			//跳转页面
			router() {
				uni.navigateTo({
					url: '../withdraw_record/withdraw_record'
				})
			},
			//申请提现
			withdraw() {
				if (this.bank != '' && this.cardid != '' && this.money != '') {
						global.$http.request({
							url:'/shopapi/user/withdrawalApp',
							data:{
								token:uni.getStorageSync('token'),
								price:this.money,
								name:this.name,
								// bank:this.bank,
								bank:this.bank_ids,
								card:this.cardid,
								bank_address:this.banker
							},
						}).then(res=>{
							if(res.data.code==200){
								uni.showToast({
									title: res.data.msg,
									icon: 'none',
									duration: 1000,
									mask: true,
								})
								this.getallmoney()
							}
						})
				} else {
					uni.showToast({
						title: '请将信息填写完整',
						icon: 'none',
						duration: 1000,
						mask: true,
					})
				}


			},
			//全部提现按钮
			all() {
				this.money = this.info.withdraw
			},
			//获取资产
			getallmoney() {
				global.$http.request({
					url: '/shopapi/user/Withdrawal',
					data: {
						token: uni.getStorageSync('token')
					}
				}).then(res => {
					var that = this
					if (res.data.code == 200) {
						that.info = res.data.data
						that.banklist = res.data.data.bank
						for (let i = 0; i < that.banklist.length; i++) {
							that.banklist[i].value = res.data.data.bank[i].id
							that.banklist[i].label = res.data.data.bank[i].name
							that.banklist[i].bank_code = res.data.data.bank[i].bank_code
						}
						console.log(that.banklist);
					}
				})
			}

		}
	}
</script>
<style lang="scss">
	page {
		font-family: PingFang SC;
		width: 750rpx;
		margin: 0 auto;
		background-color: #f7f7f7;

		.main {
			width: 750rpx;
			margin: 0 auto;

			.rights {
				padding-right: 20rpx;
				font-size: 28rpx;
				font-weight: bold;
				color: #000000;
			}

			.top {
				background-color: #fff;
				width: 750rpx;
				margin-top: 10rpx;
				padding: 21rpx 30rpx;

				.allmoney {
					padding: 5rpx 0;

					.title {
						font-size: 26rpx;
						font-family: PingFang SC;
						font-weight: bold;
						color: #999999;
					}

					text {
						display: block;
						padding: 19rpx 0 29rpx 0;
						font-size: 34rpx;
						font-weight: bold;
						color: #000000;
					}

					.smoney {
						font-size: 30rpx;
					}
				}

			}

			.content {
				width: 690rpx;
				margin: 20rpx 30rpx;
				background-color: #fff;
				border-radius: 10rpx;
				padding: 30rpx 20rpx;

				.bankcard {
					width: 650rpx;
					margin: 0rpx auto;
					background: #F7F7F7;
					border-radius: 10rpx;
					padding: 0rpx 19rpx;

					.bank {

						display: flex;
						align-items: center;
						border-bottom: 2rpx solid #CCCCCC;
						padding: 28rpx 19rpx;

						text {
							font-size: 24rpx;
							font-weight: bold;
							color: #333333;
						}

						input {
							font-size: 28rpx;
							font-weight: bold;
							color: #000000;
						}
					}

					.idcard {
						display: flex;
						align-items: center;
						padding: 27rpx 19rpx;

						text {
							font-size: 24rpx;
							font-weight: bold;
							color: #333333;
						}
						input {
							font-size: 28rpx;
							font-weight: bold;
							color: #000000;
						}
					}
				}

				.alldraw {
					padding: 50rpx 0 11rpx 20rpx;

					.tit {
						font-size: 28rpx;
						font-weight: bold;
						color: #000000;

					}

					.drawmoney {
						border-bottom: 2rpx solid #E6E6E6;
						display: flex;
						align-items: center;

						text {
							font-size: 62rpx;
							font-weight: bold;
							color: #333333;
							padding: 30rpx 0;
						}

						input {
							height: 60rpx;
							font-size: 62rpx;
							// font-weight: bold;
						}
					}

					.full_lift {
						padding-top: 38rpx;
						display: flex;
						align-items: center;
						justify-content: space-between;

						text {
							font-size: 28rpx;
							font-weight: bold;
							color: #999999;
						}

						view {
							font-size: 28rpx;
							font-weight: bold;
							color: #3079FF;
						}
					}
				}


			}

			.button {
				font-size: 32rpx;
				font-weight: 400;
				color: #FFFFFF;
				background: #E13C3D;
				border-radius: 49rpx;
				padding: 34rpx 0;
				text-align: center;
				margin: 60rpx 30rpx 29rpx 30rpx;
			}

			.ps {
				margin: 0 30rpx 30rpx 30rpx;

				.ps_tit {
					font-size: 26rpx;
					font-weight: bold;
					color: #999999;
					padding-bottom: 28rpx;
				}

				text {
					display: block;
					margin: 0 30rpx;
					font-size: 22rpx;
					font-weight: 400;
					color: #808080;
					line-height: 26rpx;
				}
			}
		}
	}
</style>
